package com.ruoyi.yuan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yuan.domain.Mainland;
import com.ruoyi.yuan.service.IMainlandService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大陆信息Controller
 * 
 * @author guifeng
 * @date 2022-08-25
 */
@Api("大陆信息")
@RestController
@RequestMapping("/yuan/mainland")
public class MainlandController extends BaseController
{
    @Autowired
    private IMainlandService mainlandService;

    /**
     * 查询大陆信息列表
     */
    @ApiOperation("查询大陆信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:mainland:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mainland mainland)
    {
        startPage();
        List<Mainland> list = mainlandService.selectMainlandList(mainland);
        return getDataTable(list);
    }

    /**
     * 导出大陆信息列表
     */
    @ApiOperation("导出大陆信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:mainland:export')")
    @Log(title = "大陆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mainland mainland)
    {
        List<Mainland> list = mainlandService.selectMainlandList(mainland);
        ExcelUtil<Mainland> util = new ExcelUtil<Mainland>(Mainland.class);
        util.exportExcel(response, list, "大陆信息数据");
    }

    /**
     * 获取大陆信息详细信息
     */
    @ApiOperation("获取大陆信息详细信息")
    @PreAuthorize("@ss.hasPermi('yuan:mainland:query')")
    @GetMapping(value = "/{mainlandId}")
    public AjaxResult getInfo(@PathVariable("mainlandId") Long mainlandId)
    {
        return AjaxResult.success(mainlandService.selectMainlandByMainlandId(mainlandId));
    }

    /**
     * 新增大陆信息
     */
    @ApiOperation("新增大陆信息")
    @PreAuthorize("@ss.hasPermi('yuan:mainland:add')")
    @Log(title = "大陆信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mainland mainland)
    {
        return toAjax(mainlandService.insertMainland(mainland));
    }

    /**
     * 修改大陆信息
     */
    @ApiOperation("修改大陆信息")
    @PreAuthorize("@ss.hasPermi('yuan:mainland:edit')")
    @Log(title = "大陆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mainland mainland)
    {
        return toAjax(mainlandService.updateMainland(mainland));
    }

    /**
     * 删除大陆信息
     */
    @ApiOperation("删除大陆信息")
    @PreAuthorize("@ss.hasPermi('yuan:mainland:remove')")
    @Log(title = "大陆信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mainlandIds}")
    public AjaxResult remove(@PathVariable Long[] mainlandIds)
    {
        return toAjax(mainlandService.deleteMainlandByMainlandIds(mainlandIds));
    }
}
